package vip.xiaonuo.applet;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.applet.dto.QuestionnaireDto;
import vip.xiaonuo.core.annotion.BusinessLog;
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
import vip.xiaonuo.core.pojo.page.PageResult;
import vip.xiaonuo.core.pojo.response.ResponseData;
import vip.xiaonuo.core.pojo.response.SuccessResponseData;
import vip.xiaonuo.modular.category.param.CategoryParam;
import vip.xiaonuo.modular.category.service.CategoryService;
import vip.xiaonuo.modular.questionnaire.param.QuestionnaireParam;
import vip.xiaonuo.modular.questionnaire.service.QuestionnaireService;
import vip.xiaonuo.modular.qusstionnaire.param.QusstionnaireParam;
import vip.xiaonuo.modular.qusstionnaire.service.QusstionnaireService;
import vip.xiaonuo.modular.screendetail.entity.ScreenDetail;
import vip.xiaonuo.modular.screendetail.param.ScreenDetailParam;

/**
 * 问卷接口
 *
 * @author wing
 *
 */
@Api(tags = "小程序问卷接口")
@RestController
public class QuestionnaireCommonController {

    @Autowired
    private QuestionnaireService questionnaireService;

    @Autowired
    private QusstionnaireService qusstionnaireService;

    @Autowired
    private CategoryService categoryService;


    @ApiOperation("甄别问卷生成和校验")
    @PostMapping("/screenGenerate")
    @BusinessLog(title = "问卷列表_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData screenGenerate(@RequestBody QuestionnaireDto questionnaireDto) {
        return new SuccessResponseData(questionnaireService.screenGenerate(questionnaireDto));
    }

    @ApiOperation("开始答题")
    @PostMapping("/answerQuestions")
    @BusinessLog(title = "开始答题", opType = LogAnnotionOpTypeEnum.QUERY)
    public SuccessResponseData answerQuestions(@RequestBody QuestionnaireDto questionnaireDto){
        QuestionnaireDto questions=questionnaireService.answerQuestions(questionnaireDto);
        return new SuccessResponseData(questions);
    }


    @ApiOperation("甄别问卷回答接口(自动审核)")
    @PostMapping("/answerScreen")
    @BusinessLog(title = "甄别问卷回答接口", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData answerScreen(@RequestBody QuestionnaireDto questionnaireDto){
       return questionnaireService.answerScreen(questionnaireDto);
    }


    /**
     * 问卷查询
     * @param qusstionnaireParam
     * @return
     */
    @ApiOperation("用户问卷_查询")
    @GetMapping("/qusstionnaire/page")
    @BusinessLog(title = "用户问卷_查询  路径参数 userId=?(必选传),receive=1(是否接收问卷0表否 1表是) ,complete=?(是否完成),ground=?(是否上架) ", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(QusstionnaireParam qusstionnaireParam) {
        return new SuccessResponseData(qusstionnaireService.page(qusstionnaireParam));
    }


    /**
     * 获取问卷分类
     * @param categoryParam
     * @return
     */
    @GetMapping("/category/list")
    @BusinessLog(title = "类别_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(CategoryParam categoryParam) {
        return new SuccessResponseData(categoryService.list(categoryParam));
    }

}
